package com.zhentao.controller;

import com.zhentao.model.common.app.pojo.Banner;
import com.zhentao.model.common.dtos.ResponseResult;
import com.zhentao.service.MaBannerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.io.IOException;

/**
 * @author 王越潇
 * @version 1.0
 * @Date 2024/9/20 19:40
 * @Type
 */
@RestController
@RequestMapping("ma/banner")
@Api(tags = "MaBanner",description = "轮播图管理")
public class MaBannerController {
    @Resource
    private MaBannerService maBannerService;
    @ApiOperation("轮播图查询")
    @GetMapping("findAll")
    public ResponseResult findAll(){
        return maBannerService.findAll();
    }
    @ApiOperation("轮播图添加")
    @PostMapping("add")
    public ResponseResult add(@RequestBody Banner banner){
        return maBannerService.add(banner);
    }
    @ApiOperation("轮播图修改")
    @PostMapping("update")
    public ResponseResult update(@RequestBody Banner banner){
        return maBannerService.update(banner);
    }
    @PostMapping("/file")
    @ApiOperation("管理端：文件上传")
    private String file(MultipartFile file) throws IOException {
        return maBannerService.file(file);
    }

    @ApiOperation("轮播图删除")
    @DeleteMapping("delete/{id}")
    public ResponseResult delete(@PathVariable("id") Integer id){
        return maBannerService.delete(id);
    }
}
